﻿using Messenger.Lib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Services;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DA_CLIENT
{
    public class SettingNetwork
    {
        public MarshalByRefObject obj;
        public MarshalByRefObject CauHinhMang()
        {
            //Thiết lập mạng
            HttpChannel kenh = new HttpChannel();
            ChannelServices.RegisterChannel(kenh);
            //StatusBar.Text = "Đang tải thiết lập mạng ...";
            try
            {
                obj = (MarshalByRefObject)RemotingServices.Connect(typeof(IServer), "http://127.0.0.1:9000/SingletonServer");
                Global.server = obj as IServer;
                (obj as RemotingClientProxy).Timeout = 5000;
                
            }
            catch
            {
                Console.WriteLine("Loi ket noi server...");
            }
            return obj;
        }

        
    }
}
